#define _CRT_SECURE_NO_WARNINGS 1
#include"MyHash.h"

namespace bit {
	template<class K, class V, class Hash =	hash_bucket::HashFunc<K> >
	class unordered_map {
		struct MapKeyOft {
			const K& operator()(const pair<K, V>& kv) {
				return kv.first;
			}
		};
	public:
		typedef typename hash_bucket::HashTable<K, pair<const K, V>, MapKeyOft, Hash>::Iterator iterator;
		//typedef typename hash_bucket::HashTable<K, pair<const K, V>, KeyOft, Hash>::Const_Iterator const_iterator;
		iterator begin() {
			return _ht.begin();
		}
		iterator end() {
			return _ht.end();
		}

		V& operator[](const K& k) {
			pair<iterator,bool>res=insert(make_pair(k, V()));
			return res.first->second;
		}

		pair<iterator, bool> insert(const pair<K,V>& kv) {
			return _ht.Insert(kv);
		}

		bool erase(const K& k) {
			return _ht.Erase(k);
		}
		pair<iterator, bool> find(const K& k) {
			return _ht.Find(k);
		}

	private:
		hash_bucket::HashTable<K, pair<const K, V>, MapKeyOft, Hash> _ht;
	};

}

